//
//  LiteratureGroupService.m
//  homeland
//
//  Created by caesar on 14-8-8.
//  Copyright (c) 2014年 xzysun. All rights reserved.
//

#import "LiteratureGroupService.h"

@implementation LiteratureGroupService

- (void)loadDataWithKey:(NSString *)keyOrNil{
    _currentPageNo = 1;
    if (self.dataList) {
        self.dataList = nil;
    }
    _dataItemName = @"LiteratureGroupEntity";
    NSDictionary *_config = [super paramDic];
    
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setValue:[_config objectForKey:@"partyMember"]forKey:@"partyMember"];
    [params setValue:[_config objectForKey:@"communityId"] forKey:@"communityId"];
    [params setValue:@"" forKey:@"userId"];
    
    if (keyOrNil) {
        [params setValue:keyOrNil forKey:@"title"];
    } else {
        [params setValue:@"" forKey:@"title"];
    }
    [self doHttpPost:SERVER_URL_LITERATURE_GROUP_LIST headers:nil path:[NSString stringWithFormat:@"/%d",_currentPageNo] parameters:params];
}

- (void)loadMoreDataWithKey:(NSString *)keyOrNil{
    NSDictionary *_config = [super paramDic];
    NSMutableDictionary *params = [NSMutableDictionary dictionary];
    [params setValue:[_config objectForKey:@"partyMember"]forKey:@"partyMember"];
    [params setValue:[_config objectForKey:@"communityId"] forKey:@"communityId"];
    [params setValue:@"" forKey:@"userId"];
    
    if (keyOrNil) {
        [params setValue:keyOrNil forKey:@"title"];
    } else {
        [params setValue:@"" forKey:@"title"];
    }
    [self doHttpPost:SERVER_URL_LITERATURE_GROUP_LIST headers:nil path:[NSString stringWithFormat:@"/%d",_currentPageNo + 1] parameters:params];
}

- (CGFloat)heightForCellAtRow:(NSIndexPath *)index{

    return 78;
}

/**展示数据*/
- (void)configCell:(UITableViewCell *)cell atIndex:(NSIndexPath *)index{
    if (self.dataList == nil || self.dataList.count == 0) {
        return;
    }
    // evaluate content insertTime
    LiteratureGroupEntity *item = [self.dataList objectAtIndex:index.row];
    LiteratureGroupCellTableViewCell *tempCell = (LiteratureGroupCellTableViewCell *)cell;
    tempCell.backgroundColor = [UIColor whiteColor];
    tempCell.titleLable.text = [CommonUtil dealNullObject:item.title];
 
    tempCell.contentLable.text = [CommonUtil dealNullObject:item.content];
 
    tempCell.selectionStyle = UITableViewCellSelectionStyleNone;
}

@end
